* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.search-box {
    position: relative;
    max-width: 500px;
    margin: 0 auto 30px;
}

.search-box input {
    width: 100%;
    padding: 15px 50px 15px 20px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.search-box input:focus {
    outline: none;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.search-box i {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
}

/* 全局同步按钮样式 */
.global-sync-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
}

.global-sync-up-btn, .global-sync-down-btn {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.global-sync-up-btn:hover, .global-sync-down-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.global-sync-up-btn.syncing, .global-sync-down-btn.syncing {
    animation: spin 1s linear infinite;
}

/* Tab页样式 */
.tab-container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    overflow: hidden;
}

.tab-header {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    align-items: center;
}

.tab-buttons {
    display: flex;
    flex: 1;
    overflow-x: auto;
}

.add-tab-btn {
    background: #f8f9fa;
    color: #6c757d;
    border: 2px dashed #dee2e6;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: 15px;
    white-space: nowrap;
}

.add-tab-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    color: #495057;
    transform: translateY(-1px);
}

.tab-btn {
    flex: 1;
    padding: 15px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background: #e9ecef;
    color: #333;
}

.tab-btn.active {
    background: white;
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-btn {
    position: relative;
}

.tab-edit-btn, .tab-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 12px;
    margin-left: 5px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tab-btn:hover .tab-edit-btn,
.tab-btn:hover .tab-delete-btn {
    opacity: 1;
}

.tab-edit-btn {
    color: #28a745;
}

.tab-edit-btn:hover {
    background: #d4edda;
}

.tab-delete-btn {
    color: #dc3545;
}

.tab-delete-btn:hover {
    background: #f8d7da;
}

.tab-content {
    padding: 25px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.tab-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.links-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    max-height: 600px;
    overflow-y: auto;
}

@media (max-width: 1200px) {
    .links-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 992px) {
    .links-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .links-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .links-grid {
        grid-template-columns: 1fr;
    }
}

.add-btn {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.sync-btn {
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.sync-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.4);
}

.sync-btn.syncing {
    animation: spin 1s linear infinite;
}



@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.links {
    display: grid;
    gap: 12px;
}

.link-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #f8f9fa;
    border-radius: 8px;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.link-item:hover {
    background: #e9ecef;
    border-left-color: #667eea;
    transform: translateX(5px);
}

/* 拖拽排序样式 */
.link-item {
    cursor: grab;
    user-select: none;
}

.link-item:active {
    cursor: grabbing;
}

.link-item.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
    z-index: 1000;
    position: relative;
}

.link-item.drag-over {
    border-left-color: #ffc107;
    background: #fff3cd;
    transform: scale(1.02);
}

.link-item.drag-over::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #ffc107;
    border-radius: 2px;
}

.link-item a {
    color: #333;
    text-decoration: none;
    font-weight: 500;
    flex: 1;
}

.link-item a:hover {
    color: #667eea;
}

.link-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.link-item:hover .link-actions {
    opacity: 1;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.edit-btn {
    color: #28a745;
}

.edit-btn:hover {
    background: #d4edda;
}

.delete-btn {
    color: #dc3545;
}

.delete-btn:hover {
    background: #f8d7da;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #333;
}

.modal h3 {
    margin-bottom: 20px;
    color: #333;
    text-align: center;
}

.form-group {
    margin-bottom: 25px;
    position: relative;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

/* 美化下拉框样式 */
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group select:hover {
    border-color: #adb5bd;
}

/* 美化文本域样式 */
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    transition: all 0.3s ease;
    line-height: 1.5;
}

.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea:hover {
    border-color: #adb5bd;
}

/* 美化标签样式 */
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 美化下拉框选项 */
.form-group select option {
    padding: 8px 12px;
    background: white;
    color: #495057;
    font-size: 14px;
}

.form-group select option:hover {
    background: #f8f9fa;
}

/* 优化表单组间距和布局 */
.form-group {
    margin-bottom: 25px;
    position: relative;
}

.form-group:last-child {
    margin-bottom: 0;
}

/* 为必填字段添加标识 */
.form-group label.required::after {
    content: ' *';
    color: #dc3545;
    font-weight: bold;
}

.form-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
}

.form-buttons button {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.form-buttons button[type="submit"] {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
}

.form-buttons button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.form-buttons button[type="button"] {
    background: #6c757d;
    color: white;
}

.form-buttons button[type="button"]:hover {
    background: #5a6268;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .categories {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .category {
        padding: 20px;
    }
    
    .modal-content {
        margin: 20% auto;
        padding: 20px;
    }
    
    .form-buttons {
        flex-direction: column;
    }
}

/* 搜索高亮 */
.highlight {
    background-color: #fff3cd;
    padding: 2px 4px;
    border-radius: 3px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .favorites-section {
        top: 15px;
        right: 15px;
    }
    
    .favorites-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .links-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .tab-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .tab-buttons {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .global-sync-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .global-sync-up-btn,
    .global-sync-down-btn {
        width: 100%;
    }
}

/* 收藏夹样式 */
.favorites-section {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
}

.favorites-btn {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.favorites-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.favorites-modal {
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

.favorites-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    flex-wrap: wrap;
}

.add-folder-btn,
.add-favorite-btn {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.add-folder-btn:hover,
.add-favorite-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.3);
}

.favorites-content {
    min-height: 300px;
}

.favorite-folder {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 15px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.favorite-folder:hover {
    border-color: #4ecdc4;
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.1);
}

.folder-header {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    border-bottom: 1px solid #dee2e6;
}

.folder-header:hover {
    background: linear-gradient(135deg, #e9ecef, #dee2e6);
}

.folder-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.folder-icon {
    font-size: 20px;
    color: #4ecdc4;
}

.folder-name {
    font-weight: 600;
    color: #495057;
}

.folder-count {
    background: #4ecdc4;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.folder-actions {
    display: flex;
    gap: 5px;
}

.folder-action-btn {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    color: #6c757d;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.folder-action-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.folder-content {
    padding: 15px;
    display: none;
}

.folder-content.expanded {
    display: block;
}

.favorite-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    margin: 5px 0;
    background: #f8f9fa;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.favorite-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.favorite-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.favorite-icon {
    color: #ff6b6b;
    font-size: 16px;
}

.favorite-details {
    flex: 1;
}

.favorite-name {
    font-weight: 600;
    color: #495057;
    margin-bottom: 2px;
}

.favorite-url {
    color: #6c757d;
    font-size: 12px;
    word-break: break-all;
}

.favorite-description {
    color: #868e96;
    font-size: 12px;
    margin-top: 2px;
    font-style: italic;
}

.favorite-actions {
    display: flex;
    gap: 5px;
}

.favorite-action-btn {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    color: #6c757d;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.favorite-action-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.favorite-action-btn.delete:hover {
    background: #ff6b6b;
    color: white;
}

.empty-favorites {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.empty-favorites i {
    font-size: 48px;
    color: #dee2e6;
    margin-bottom: 15px;
}

.empty-favorites h4 {
    margin-bottom: 10px;
    color: #495057;
}

.empty-favorites p {
    margin-bottom: 20px;
}

/* 空文件夹样式 */
.empty-folder {
    text-align: center;
    padding: 30px 20px;
    color: #6c757d;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 10px 0;
}

/* Tab名称内联编辑样式 */
.tab-name-edit-input {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 2px solid #667eea !important;
    border-radius: 6px !important;
    padding: 4px 8px !important;
    font-size: inherit !important;
    font-family: inherit !important;
    color: #333 !important;
    width: 120px !important;
    outline: none !important;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2) !important;
    transition: all 0.3s ease !important;
}

.tab-name-edit-input:focus {
    border-color: #4ecdc4 !important;
    box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.1) !important;
    background: white !important;
}

.empty-folder p {
    margin-bottom: 15px;
    color: #868e96;
    font-style: italic;
}

.empty-folder .add-favorite-btn {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.empty-folder .add-favorite-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.3);
}

/* 响应式收藏夹 */
@media (max-width: 768px) {
    .favorites-modal {
        max-width: 95vw;
        margin: 10px;
    }
    
    .favorites-toolbar {
        flex-direction: column;
    }
    
    .add-folder-btn,
    .add-favorite-btn {
        width: 100%;
        justify-content: center;
    }
    
    .folder-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .folder-actions {
        align-self: flex-end;
    }
    
    .favorite-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .favorite-actions {
        align-self: flex-end;
    }
}

/* 收藏夹表单特殊样式 */
.favorites-modal .form-group select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234ecdc4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
}

.favorites-modal .form-group select:focus {
    border-color: #4ecdc4;
    box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.1);
}

.favorites-modal .form-group input:focus,
.favorites-modal .form-group textarea:focus {
    border-color: #4ecdc4;
    box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.1);
}

/* 文件夹图标选择器美化 */
#folderIcon {
    font-family: 'Font Awesome 6 Free', sans-serif;
}

#folderIcon option {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 表单输入框占位符样式 */
.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #adb5bd;
    font-style: italic;
    opacity: 0.8;
}
